Component({
  mixins: [],
  data: {
    loggerShow: false,
    boxShow: false,
    topNum: 968,
    heightNum: 968,
    tagArray: [],
    logArray: [],
    tabActiveIndex: 1,
    animationState: false,
  },
  async didMount() {
    // 获取 Logger 是否显示的状态
    this.getLoggerShow();
    // 绑定全局的方法，监控是否需要显示 Logger
    my.mfutil.emitter.on("changeLoggerShow", () => {
      this.getLoggerShow();
    });
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    // 获取显示logger
    async getLoggerShow() {
      if (my.mfutil && my.mfutil.logger && !this.data.loggerShow) {
        const loggerShow = await my.mfutil.logger.getLoggerShow();
        if (loggerShow) {
          this.setData({
            loggerShow,
          });
        }
      }
    },
    //  获取日志
    async get(index) {
      if (my.mfutil.logger) {
        let res = await my.mfutil.logger.get();
        this.setData({
          tagArray: res,
          logArray: res[index].logArray
        })
      }
    },
    boxAnime() {
      if (this.data.boxShow) {
        this.animeHiddenBox();
        my.setGestureMode({ "gestureMode": "default" });
      } else {
        this.animeShowBox();
        my.setGestureMode({ "gestureMode": "inner" });
      }
    },
    // 弹窗展示
    async animeShowBox() {
      await this.get(0);
      this.setData({
        boxShow: true,
        topNum: 0,
        animationState: true,
      });
    },
    // 弹窗隐藏
    animeHiddenBox() {
      let _device = my.getSystemInfoSync();
      // this._vanimation.top(_device.screenHeight).step()
      this.setData({
        // animation: this._vanimation.export(),
        tabActiveIndex: 1,
        boxShow: false,
        topNum: 968,
      });
    },
    //  tab切换
    tabSwitch(e) {
      const { currentTarget: { dataset: { index } } } = e;

    },
    async clearLog() {
      await my.mfutil.logger.clear();
      this.setData({
        logArray: []
      })
    }
  },
});
